<template>
  <div class="login">
    <div class="bg">
      <div class="card">
        <div class="title">中古包总管理系统</div>
        <a-form
          :model="formState"
          name="normal_login"
          class="login-form"
          @finish="onFinish"
          @finishFailed="onFinishFailed"
        >
          <a-form-item
            name="username"
            :rules="[{ required: true, message: '请输入11位数登陆手机号!' }]"
          >
            <a-input
              :bordered="false"
              class="h-form-lebel h-form-input"
              v-model:value="formState.username"
              placeholder="输入11位数登陆手机号"
            >
            </a-input>
          </a-form-item>
          <a-form-item
            name="code"
            :rules="[{ required: true, message: '请输入验证码!' }]"
          >
            <div class="form-flex">
              <a-input
                :bordered="false"
                class="h-form-lebel h-form-input"
                v-model:value="formState.code"
                placeholder="请输入验证码"
              >
              </a-input>
              <div class="h-form-lebel h-form-code">验证码</div>
            </div>
          </a-form-item>
          <a-form-item>
            <div
              class="h-form-lebel form-btn"
              @click="handleLogin"
              >登录</div
            >
          </a-form-item>
        </a-form>
      </div>
    </div>
  </div>
</template>
<script setup>
import { ref, reactive } from "vue";
import { useRouter } from "vue-router";
import { useUserStore } from "@/store/modules/user";
const router = useRouter();
const userStore = useUserStore();

const formState = reactive({
  username: "",
  code: ""
});
const onFinish = (values) => {
  console.log("Success:", values);
};
const onFinishFailed = (errorInfo) => {
  console.log("Failed:", errorInfo);
};
const handleLogin = () => {
  userStore.Login(formState).then(res => {
    console.log("Success:", res);
    console.log(router)
    router.push({ path: "/" });
  });
};

</script>
<style lang="less" scoped>
.flex{
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.login {
  height: 100vh;
  overflow: hidden;
  .bg {
    background: url("/image/login_bg.jpg") no-repeat center center;
    background-size: 100% 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    .card {
      background-color: #ffffff;
      box-sizing: border-box;
      padding: 48px 88px;
      width: 600px;
      .title {
        font-size: 24px;
        font-family: PingFang SC-Semibold, PingFang SC;
        font-weight: 600;
        color: #262e47;
        margin-bottom: 40px;
        text-align: center;
      }
    }
  }
  .h-form-lebel {
    height: 48px;
  }
  .h-form-code{
    background-color: #262e47;
    text-align: center;
    line-height: 48px;
    border-radius: 8px;
    width: 100px;
    font-size: 12px;
    font-family: PingFang SC-Semibold, PingFang SC;
    font-weight: 600;
    color: #ffffff;
    cursor: pointer;
  }
  .form-btn {
    width: 100%;
    font-size: 16px;
    font-family: PingFang SC-Semibold, PingFang SC;
    font-weight: 600;
    color: #ffffff;
    background-color: #262e47;
    text-align: center;
    line-height: 48px;
    border-radius: 8px;
    cursor: pointer;
  }
  .h-form-input {
    background-color: #f3f5f7;
  }
  .form-flex {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
  }
}
</style>
